<?php

namespace App\Transformers\Order;

use App\Models\Order;
use League\Fractal\TransformerAbstract;

class ConsumptionOrderTransformer extends TransformerAbstract
{
    public function transform(Order $order)
    {
        return [
            'id' => $order->id,
            'order_number' => $order->order_number ?? '',
            'user_name' => $order->user_name ?? '',
            'total_num' => $order->total_num ?? '',
            'total_price' => $order->total_price ?? '',
            'pay_price' => $order->pay_price ?? '',
            'pay_time' => $order->pay_time ?? '',
            'created_at' => $order->created_at ? $order->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $order->updated_at ? $order->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }
}
